﻿@model IEnumerable<KRM.Core.vLoadDetail>
<script>
    InitAjaxTable($(".listloaddetailtable"));
    InitTableSelected();
</script>
@Html.Partial("Partial/_MessageResult")

<table class="table table-bordered table-fix krmtable listloaddetailtable tbl-selected" data-height="250">
    <thead>
        <tr>
            <th></th>
            <th>LoadID</th>
            <th>LoadCode</th>
            <th>LoadStatus</th>
            <th onclick="sortInViewLoad('CreatedDate')">CreatedDate</th>
            <th>Username</th>
            <th onclick="sortInViewLoad('PlannedDeliveryDate')">PlannedDeliveryDate</th>
            <th onclick="sortInViewLoad('DespatchDate')">DespatchDate</th>
            <th>CarrierName</th>
            <th>DriverName</th>
            <th>Name</th>
            <th>LoadStatusID</th>
            <th>CreateByUserID</th>
            <th>VehicleID</th>
            <th>CarrierID</th>
            <th>DriverID</th>
            <th>VehicleMaxWeight</th>
            <th>ProcessOrder</th>
            <th>IsZoned</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            var move = item.LoadStatus == "UNPLANNED" || item.LoadStatus == "PLANNED" || item.LoadStatus == "BOOKED IN";
            <tr onclick="listloaddetailselected(@item.LoadID)">
                <td>
                    <div class="btn-group">
                        <a href="#" data-toggle="dropdown" class="btn dropdown-toggle"><i class="icon-cog"></i><span class="caret"></span></a>
                        <ul class="dropdown-menu dropdowm-right">
                            @*<li><a href="#ViewSendLoadDetail" data-toggle="modal" role="button" onclick="SendLoadDetail(@item.LoadID)"> Send Load Detail</a></li>
                            <li><a href="javascript:;" onclick="viewdrivermanifest('@item.LoadCode')">View Driver Manifest</a></li>
                            <li><a href="javascript:;" onclick="viewdeliverynote('@item.LoadCode')">View Delivery Note</a></li>
                            <li><a href="javascript:;" onclick="viewboxlabels('@item.LoadCode')">View Box Label</a></li>
                            <li><a href="javascript:;" onclick="viewdespatchlabels('@item.LoadCode')">View Despatch Labels</a></li>
                            <li><a href="javascript:;" onclick="viewdriverloadacceptancesummary('@item.LoadCode')">View Driver Load Acceptance Summary</a></li>*@
                            <li><a href="javascript:;" onclick="PopupCenter('/load/rearrangedrops?loadid=@item.LoadID', 800,600)">Rearrange Drops</a></li>
                            @*<li><a href="javascript:;" onclick="unplanload(@item.LoadID)">Unplan Load</a></li>*@
                            <li><a href="javascript:;" onclick="PopupCenter('/load/viewaudit?loadid=@item.LoadID', 700,550)">View Audit</a></li>
                            @*<li><a href="javascript:;" onclick="PopupCenter('/load/senddespatchedconfirmationsms?loadid=@item.LoadID', 700,550)">Send Despatched Confirmation SMS</a></li>
                            <li><a href="javascript:;" onclick="@(move ? "PopupCenter('/load/MoveWareHouseAndCarrier?loadid=" + item.LoadID + "',500,320)" :
                                                                      "alert('Load has already had picking documents generated so its not possible to change the Courier or Warehouse')")">Move Courier And Warehouse</a></li>
                            <li><a href="javascript:;" onclick="viewnewdrivermanifest('@item.LoadCode')">View New Driver Manifest</a></li>
                            <li><a href="javascript:;" onclick="viewnewpickingsummary('@item.LoadCode')">View New Picking Summary</a></li>
                            <li><a href="javascript:;" onclick="viewnewdespatchlabels('@item.LoadCode')">View New Despatch Labels</a></li>
                            <li><a href="javascript:;" onclick="viewnewpackinglist('@item.LoadCode')">View New Packing List</a></li>
                            <li><a href="javascript:;" onclick="PopupCenter('/load/viewloadphoto?loadid=@item.LoadID&loadcode=@item.LoadCode', 900,650)">View Load Photo</a></li>*@
                        </ul>
                    </div>
                </td>
                <td>@item.LoadID</td>
                <td>@item.LoadCode</td>
                <td>@item.LoadStatus</td>
                <td>@item.CreatedDate</td>
                <td>@item.Username</td>
                <td>@item.PlannedDeliveryDate</td>
                <td>@item.DespatchDate</td>
                <td>@item.carrierName</td>
                <td>@item.DriverName</td>
                <td>@item.Name</td>
                <td>@item.LoadStatusID</td>
                <td>@item.CreatedByUserID</td>
                <td>@item.VehicleID</td>
                <td>@item.CarrierID</td>
                <td>@item.DriverID</td>
                <td>@item.VehicleMaxWeight</td>
                <td>@item.ProcessOrder</td>
                <td>@item.IsZoned</td>
            </tr>
        }
    </tbody>
</table>
